file(GLOB_RECURSE LWIP_SOURCES
        "api/*.c"
        "apps/*.c"
        "core/*.c"
        "netif/*.c"
)

file(GLOB_RECURSE LWIP_HEADERS
        "include/*.h"
)

# 设置安全编译选项
set(lwip_SEC_FLAGS
        -fstack-protector-strong
        -Werror
        -Wall
        -Wtrampolines
        -fPIC
        -D_FORTIFY_SOURCE=2
)

# 设置链接器安全选项
set(lwip_LINKER_SEC_FLAGS
        -Wl,-z,relro,-z,now
        -Wl,-z,noexecstack
)

# 设置其他 CFLAGS
set(lwip_EXTRA_FLAGS
        -D__USE_GNU=1
        -D_GNU_SOURCE=1
        -O2
        -g
)

add_library(lwip ${LWIP_SOURCES} ${LWIP_HEADERS})
target_include_directories(lwip PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}/include
)
#target_include_directories(lwip ${dpdk_INCLUDE_DIRS})
target_link_libraries(lwip PRIVATE PkgConfig::dpdk)
#target_link_libraries(lwip ${dpdk_LIBRARIES})

target_compile_options(lwip PRIVATE
        ${lwip_SEC_FLAGS}
        ${lwip_EXTRA_FLAGS}
)
target_link_options(lwip PRIVATE
        ${lwip_LINKER_SEC_FLAGS}
)
